import type { UserInfo } from '@vben/types';

import { requestClient } from '#/api/request';

/**
 * 获取用户信息
 */
export async function getUserInfoApi() {
  return requestClient.get<UserInfo>('/user/info');
}

type user = {
  createTime: string;
  email: string;
  headerUrl: string;
  id: number;
  status: 0 | 1;
  type: 0 | 1;
  username: string;
};

interface userListResult {
  total: number;
  users: user[];
}

export async function getUserListApi() {
  return requestClient.get<userListResult>('admin/user/list');
}

export async function updateUserInfoApi(data: user) {
  return requestClient.put(`admin/user/update/${data.id}`, data);
}

interface manageInfo {
  visitCount: {
    current: number;
    total: number;
  };
  userCount: {
    current: number;
    total: number;
  };
  downloadCount: {
    current: number;
    total: number;
  };
  usageCount: {
    current: number;
    total: number;
  };
}

export function getManageInfo() {
  return requestClient.get<manageInfo>('manage/info');
}

export function delUserApi(id: string) {
  return requestClient.delete(`admin/user/delete/${id}`);
}
